function myNew(fun, ...args) {
    let obj = Object.create(fun.prototype)
    let result = fun.apply(obj, args)
    return typeof result === 'object' || typeof result === 'function' ? result : obj
}

// 测试 function Person(name, age) { this.name = name; this.age = age; }
function Person(name, age) {
    this.name = name
    this.age = age
}

let person = myNew(Person, "Alice", 25);
console.log(person); // Person { name: 'Alice', age: 25 }


